package com.lingx.model.impl.interpreter;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.lingx.model.impl.AbstractInterpreter;
import com.lingx.service.LingxService;
@Component
public class ImageInterpreter extends AbstractInterpreter{

	private static final long serialVersionUID = -663638321838681629L;
	@Resource
	private LingxService lingxService;
	
	public ImageInterpreter() {
		super("ImageInterpreter","图片显示<img/>");
	}
	@Override
	public Object input(Object value) throws Exception {
		return value;
	}

	@Override
	public Object output(Object value) throws Exception {
		String temp="<a href='%s' target='_blank'><img width='50' src='%s' /></a>";
		return String.format(temp, value.toString(), value.toString());
		/*
		String uriPrev=this.lingxService.getConfigValue("lingx.file.download.path", "http://127.0.0.1");
		String temp="<a href='%s' target='_blank'><img width='50' src='%s' /></a>";
		if(value!=null&&!"".equals(value.toString())) {
			String value1=value.toString();
			if(value1.startsWith("http")) {
				return String.format(temp, value.toString(), value.toString());
			}else {
				return String.format(temp,uriPrev+ value.toString(),uriPrev+ value.toString());
			}
		}
		
		else return value;*/
	}

}
